package com.frain.springcloud.listener.sublistener;

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import com.frain.springcloud.listener.entity.MyEvent;
import com.frain.springcloud.listener.entity.MyOneEvent;

@Component
public class MyListenerOne implements ApplicationListener<MyEvent> {

    @Override
    public void onApplicationEvent(MyEvent event) {

        if (event instanceof MyOneEvent) {
            MyOneEvent oneEvent = (MyOneEvent) event;
            System.out.println(oneEvent.getSource());
            System.out.println(oneEvent.getUserName());
            System.out.println(oneEvent.getPassword());
            oneEvent.sayOne();

        }

    }

}
